﻿function login(){
	//alert(11);
	var data = $('#loginForm').serialize();
	 //writeObj(data)
	$.post(
		"/Login/loginadmin",data,
		function(data){
		   //writeObj(data); 
		    if(data==1){
			   document.location.href='/Index/main';
			}else if(data==2){
			   showWarning('验证码错误');		   
			}else if(data==3){
				showWarning('密码错误')	
			}
		},
		"json"
	);
	
	
}
$(function(){
    $("input[name='account']").focus();
});
function cleardata(){
    $('#loginForm').form('clear');
}
function writeObj(obj){ 
 var description = ""; 
 for(var i in obj){ 
  var property=obj[i];
  description+=i+" = "+property+"\n"; 
 }
 alert(description);
};
function showAlert(text) {
    var call = false;
    var type = 'error';
    if (arguments.length > 1) {
        call = arguments[2];
        type = arguments[1] || type;
    }
    if (!call) $.messager.alert(getTranslation('Warning'), getTranslation(text));
    else $.messager.alert(getTranslation('Warning'), getTranslation(text), type, call);
}
function showWarning(text) {
    showAlert(text, 'warning',
    function() {});
}
function showInfo(text) {
    var call = false;
    if (arguments.length > 1) {
        call = arguments[1];
    }
    if (!call) $.messager.alert(getTranslation('Info'), getTranslation(text), 'info');
    else $.messager.alert(getTranslation('Info'), getTranslation(text), 'info', call);
}
function showError(text) {
    var call = false;
    if (arguments.length > 1) {
        call = arguments[1];
    }
    if (!call) $.messager.alert(getTranslation('Error'), getTranslation(text), 'error');
    else $.messager.alert(getTranslation('Error'), getTranslation(text), 'error', call);
}
function showConfirm(text, f) {
    $.messager.confirm(getTranslation('Confirm'), getTranslation(text), f);
}
function showOk() {
    $.messager.show({
        'title': getTranslation('Ok'),
        'msg': 'Your request submitted successfully.',
        'showType': 'fade',
        'timeout': 1000
    });
}
function getTranslation(text) {
    if (typeof text == 'undefined') return '';
    if (!text) {
        return '';
    }
    if (typeof text == 'number') {
        text = text.toString();
    }
    translation = lang_vars[text.trim()];
    if ((translation == 'null' || !translation) && typeof(lang_vars[text]) != 'undefined') translation = text;
    return translation ? translation: text;
}
